﻿using BLL;
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace HRP.Private.Departamentos
{
    public partial class Criar : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            gravarBut.Click += gravarBut_Click;
            formPanel.Visible = true;
            msgPanel.Visible = false;
        }

        void gravarBut_Click(object sender, EventArgs e)
        {
            if (!Page.IsValid)
                return;

            if (Session["idclient"] != null && Session["EmpresaActual"] != null && Session["userid"]!=null)
            {
                int id_cliente = (int)Session["idclient"];
                string userId = Session["userid"].ToString();
                hrp_empresas empresa = (hrp_empresas)Session["EmpresaActual"];
                int depId = Departamento_BLL.Instance.criarDepartamento(id_cliente, userId, string.Empty, empresa.id, nomeTB.Text.Trim(), obsTB.Text.Trim());
                if (depId > 0)
                {
                    formPanel.Visible = false;
                    msgPanel.Visible = true;
                }
            }
        }
    }
}